package com.hx.order.service.impl;

import java.util.List;
import com.hx.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.hx.order.mapper.OrdersMapper;
import com.hx.order.domain.Orders;
import com.hx.order.service.IOrdersService;

/**
 * 订单表Service业务层处理
 *
 * @author ord
 * @date 2023-05-28
 */
@Service
public class OrdersServiceImpl implements IOrdersService {
    @Autowired
    private OrdersMapper ordersMapper;

    @Autowired
    private OrdersServiceImpl ordersService;

    /**
     * 查询订单表
     *
     * @param ordId 订单表主键
     * @return 订单表
     */
    @Override
    public Orders selectOrdersByOrdId(Long ordId)
    {
        return ordersMapper.selectOrdersByOrdId(ordId);
    }

    /**
     * 查询订单表列表
     *
     * @param orders 订单表
     * @return 订单表
     */
    @Override
    public List<Orders> selectOrdersList(Orders orders)
    {
        return ordersMapper.selectOrdersList(orders);
    }

    /**
     * 新增订单表
     *
     * @param orders 订单表
     * @return 结果
     */
    @Override
    public int insertOrders(Orders orders)
    {
        System.out.println(orders);
        orders.setCreateTime(DateUtils.getNowDate());
        return ordersMapper.insertOrders(orders);
    }

    /**
     * 修改订单表
     *
     * @param orders 订单表
     * @return 结果
     */
    @Override
    public int updateOrders(Orders orders)
    {
        orders.setStatus(1);
        orders.setDeliveryTime(DateUtils.getNowDate());
        orders.setDeliverySn(DateUtils.dateTimeNow() + System.currentTimeMillis());
        return ordersMapper.updateOrders(orders);
    }

    /**
     * 批量删除订单表
     *
     * @param ordIds 需要删除的订单表主键
     * @return 结果
     */
    @Override
    public int deleteOrdersByOrdIds(Long[] ordIds)
    {
        return ordersMapper.deleteOrdersByOrdIds(ordIds);
    }

    /**
     * 删除订单表信息
     *
     * @param ordId 订单表主键
     * @return 结果
     */
    @Override
    public int deleteOrdersByOrdId(Long ordId)
    {
        return ordersMapper.deleteOrdersByOrdId(ordId);
    }
}
